// Copyright Epic Games, Inc. All Rights Reserved.
#include "GameFeatureAction_AddGameplayCuePath.h"

#if WITH_EDITOR
#include "Misc/DataValidation.h" // 数据验证相关
#endif

#include UE_INLINE_GENERATED_CPP_BY_NAME(GameFeatureAction_AddGameplayCuePath) // 包含自动生成的代码

#define LOCTEXT_NAMESPACE "GameFeatures" // 定义本地化文本命名空间

/**
 * 构造函数
 */
UGameFeatureAction_AddGameplayCuePath::UGameFeatureAction_AddGameplayCuePath()
{
	// 添加一个常用的默认路径
	DirectoryPathsToAdd.Add(FDirectoryPath{ TEXT("/GameplayCues") }); // 添加默认路径
}

#if WITH_EDITOR
/**
 * 数据验证方法
 */
EDataValidationResult UGameFeatureAction_AddGameplayCuePath::IsDataValid(FDataValidationContext& Context) const
{
	EDataValidationResult Result = Super::IsDataValid(Context); // 调用父类数据验证

	for (const FDirectoryPath& Directory : DirectoryPathsToAdd) // 遍历要添加的目录
	{
		if (Directory.Path.IsEmpty()) // 检查路径是否为空
		{
			const FText InvalidCuePathError = FText::Format(LOCTEXT("InvalidCuePathError", "'{0}'不是有效的路径！"), FText::FromString(Directory.Path)); // 创建错误文本
			Context.AddError(InvalidCuePathError); // 添加错误
			Result = CombineDataValidationResults(Result, EDataValidationResult::Invalid); // 组合验证结果
		}
	}

	return CombineDataValidationResults(Result, EDataValidationResult::Valid); // 返回组合后的验证结果
}
#endif	// WITH_EDITOR

#undef LOCTEXT_NAMESPACE // 取消定义本地化文本命名空间